<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="application-name" content="cmv">
    <meta name="description" content="长宁规划土地综合展示平台">
    <meta name="author" content="上海市测绘院">
    <link rel="shortcut icon" href="./images/logo.png">

    <title>长宁规划土地综合展示平台</title>

    <link rel="stylesheet" type="text/css"
          href="http://10.207.204.31:80/arcgis_js_api/library/3.20/esri/css/esri.css">
    <link rel="stylesheet" type="text/css" href="./css/theme/flat/flat.css">
    <link rel="stylesheet" type="text/css" href="./css/cmv-theme-overrides.css">
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="./css/main.css">
</head>
<body class="cmv flat">

<script type="text/javascript">
    var s = window.location.search, q = s.match(/locale=([^&]*)/i);
    var locale = (q && q.length > 0) ? q[1] : null;
    window.dojoConfig = {
        locale: locale,
        async: true
    };
</script>

<script src="http://10.207.204.31:80/arcgis_js_api/library/3.20/init.js"></script>

<script>
    var GLOBAL_TOKEN = '';
    // test表示测试环境，其他表示部署环境
    var GLOBAL_STATUS = 'test';

    // 获取TOKEN
    var xmlhttp = new XMLHttpRequest();
    var OneMapHost = 'http://map.cn.gov';
    var url = '';

    if (GLOBAL_STATUS === 'test') {
        url = OneMapHost + '/RemoteTokenServer?request=getToken&username=cngtj&password=cngtj12345&clientid=ref.http://127.0.0.1&expiration=500';
    } else {
        url = OneMapHost + '/RemoteTokenServer?request=getToken&username=cngtj&password=cngtj12345&clientid=ref.http://10.207.204.11&expiration=500';
    }

    xmlhttp.open('GET', url, false);
    xmlhttp.send();
    console.log(xmlhttp.responseText)
    GLOBAL_TOKEN = xmlhttp.responseText.substr(0, xmlhttp.responseText.length - 2);

    //构造一个AJAX请求，获取SOAP WebService的元数据，借助Response Header中的Set-Cookie，在客户端将Token以Cookie形式保存下来
    xmlhttp.open('GET', OneMapHost + '/OneMapServer/rest/services/address_p/Transfer?token=' + GLOBAL_TOKEN, false);
    xmlhttp.withCredentials = true; //withCredentials设置true,让浏览器发送HTTP请求时带上客户端的Cookie
    xmlhttp.send();

</script>

<script src="js/basic.js"></script>
<script src="js/config/app.js"></script>
<script type="text/javascript">
    var showLayer, hideLayer, locateByXY, locateByObjID, setMapClickDefault,
        clearFeatures, fullMapZone;
    require([
        'dojo/topic'
    ], function (topic) {

        //打开图层接口
        showLayer = function (layerid) {
            topic.publish('layerShow/' + layerid);
        };

        //关闭图层接口
        hideLayer = function (layerid) {
            topic.publish('layerHide/' + layerid);

        };

        //根据xy地图定位功能接口
        locateByXY = function (x, y) {
            topic.publish('locateByXY', {x: x, y: y});
        };

        //根据objID对图形进行定位,并抛出查询结果
        locateByObjID = function (objID, currentModule) {
            topic.publish('locateByObjID', {objID: objID, currentModule: currentModule});
        };

        //设置鼠标为点击状态
        setMapClickDefault = function () {
            topic.publish('mapClickMode/resetToggleState');
        };

        //清除图上高亮
        clearFeatures = function () {
            topic.publish('find/clear');
        };

        //全图
        fullMapZone = function () {
            topic.publish('fullMapZone');
        };
    });
</script>
</body>
</html>
